/*
* BankApplication
*
* r1
*
* GNU General Public License v3.0
*/

package com.acme.bankapp;

import com.acme.bankapp.domain.bank.*;
import com.acme.bankapp.service.bank.*;

public class BankApplication {

	private static Bank bank = new Bank();
	private static BankService bankService = new BankService();
	
	private static void addClient(String name, Gender gender, Account account) {
		Client client;
		
		client = new Client(name, Gender.MALE);
		client.getAccounts()[0] = account;
		BankApplication.bankService.addClient(BankApplication.bank, client);
	}
	
	private static void printMaximumAmountToWithdraw(Bank bank) {
		BankApplication.bankService.printMaximumAmountToWithdraw(bank);
	}
	
	public static void main(String[] args) {

		addClient("Putin", Gender.MALE, new CheckingAccount(0, 1000000));
		addClient("Ann", Gender.FEMALE, new SavingsAccount(100));
		addClient("Ya", Gender.MALE, new CheckingAccount(200, 1000));
		addClient("Noob", Gender.FEMALE, new SavingsAccount(300));

		modifyBank(BankApplication.bank);
		
		printBalance(BankApplication.bank);
		
		printMaximumAmountToWithdraw(BankApplication.bank);
	}
	
	private static void modifyBank(Bank bank) {
		Client[] clients = bank.getClients();
		
		clients[0].getAccounts()[0].withdraw(100);
		clients[1].getAccounts()[0].deposit(100);
		clients[2].getAccounts()[0].withdraw(25);
		clients[2].getAccounts()[0].deposit(598);
		clients[2].getAccounts()[0].withdraw(478);
	}
	
	private static void printBalance(Bank bank) {
		for(Client client : bank.getClients()) {
			if(client != null) {
				System.out.println(client.getClientSalutation() + "'s balance: " + client.getAccounts()[0].getBalance());
			}
		}
	}
	
}
